#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
#include<string>
using namespace std;

class Solution {
public:
    int searchInsert(vector<int>& nums, int target) {
        int flg = -1;
        for (int i = 0; i < nums.size(); i++)
        {
            if (nums[i] == target)
            {
                return i;
            }
            if (nums[i] <= target)
            {
                flg = i;
            }

        }
        return flg + 1;
    }
};